package cn.structure.edp;

import cn.structure.ClassEntity;
import cn.structure.MethodEntity;

import java.util.Objects;

public class ExtendMethod extends EdpEntity {
    private ClassEntity originalBehavior;
    private MethodEntity operation;
    private ClassEntity extendedBehavior;
    private MethodEntity operation2;

    public ExtendMethod(ClassEntity originalBehavior, MethodEntity operation, ClassEntity extendedBehavior, MethodEntity operation2) {
        super();
        this.originalBehavior = originalBehavior;
        this.operation = operation;
        this.extendedBehavior = extendedBehavior;
        this.operation2 = operation2;
    }

    public enum Role {
        originalBehavior, operation, extendedBehavior, operation2
    }

    public ClassEntity getOriginalBehavior() {
        return originalBehavior;
    }

    public void setOriginalBehavior(ClassEntity originalBehavior) {
        this.originalBehavior = originalBehavior;
    }

    public MethodEntity getOperation() {
        return operation;
    }

    public void setOperation(MethodEntity operation) {
        this.operation = operation;
    }

    public ClassEntity getExtendedBehavior() {
        return extendedBehavior;
    }

    public void setExtendedBehavior(ClassEntity extendedBehavior) {
        this.extendedBehavior = extendedBehavior;
    }

    public MethodEntity getOperation2() {
        return operation2;
    }

    public void setOperation2(MethodEntity operation2) {
        this.operation2 = operation2;
    }

    @Override
    public String toString() {
        final StringBuilder sb = new StringBuilder("ExtendMethod{\n\t");
        sb.append(super.toString());
        sb.append("\n\t\"originalBehavior\":")
                .append(originalBehavior);
        sb.append(",\n\t\"operation\":")
                .append(operation);
        sb.append(",\n\t\"extendedBehavior\":")
                .append(extendedBehavior);
        sb.append(",\n\t\"operation2\":")
                .append(operation2);
        sb.append("\n}");
        return sb.toString();
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        if (!super.equals(o)) return false;
        ExtendMethod that = (ExtendMethod) o;
        return Objects.equals(originalBehavior, that.originalBehavior) &&
                Objects.equals(operation, that.operation) &&
                Objects.equals(extendedBehavior, that.extendedBehavior) &&
                Objects.equals(operation2, that.operation2);
    }

    @Override
    public int hashCode() {
        return Objects.hash(super.hashCode(), originalBehavior, operation, extendedBehavior, operation2);
    }
}
